from PyPDF2 import PdfWriter, PdfReader


def merge_pdf(in_files, out_file='合并结果.pdf'):
    pdf_writer = PdfWriter()
    for inFile in in_files:
        pdf_reader = PdfReader(open(inFile, 'rb'))
        for index in range(len(pdf_reader.pages)):
            pdf_writer.add_page(pdf_reader.pages[index])
        # 最后,统一写入到输出文件中
        pdf_writer.write(open(out_file, 'wb'))


merge_pdf([r'E:\大学学科\供应链管理\1封面.pdf', r'E:\大学学科\供应链管理\2正文.pdf'])
